<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of producto_model
 *
 * @author Neil
 */
class producto_model extends CI_Model {

    public function Productos() {
        $query = $this->db->query('select * from producto');
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

    public function regMod($codigo, $data) {
        if ($codigo == '') {
            $this->db->insert('producto', $data);
        } else {
            $this->db->where('cod_prod', $codigo);
            $this->db->update('producto', $data);
        }
    }

    public function listarxCod($cod) {
        $query = $this->db->query('SELECT * FROM producto where cod_prod=?', $cod);
        return $query->result();
    }

    public function comboProducto() {
        $query = $this->db->query('select cod_prod as codigo, desc_prod as descripcion from producto');
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

}

?>
